layui.define([ 'form', 'laydate', 'table','sincerityApi'], function(exports) {
    var form = layui.form;
    var sincerityApi = layui.sincerityApi;
    var index = layui.index;
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                 form.on('submit(form)', function(){
                     sincerityApi.enterpriseadd($('#addForm'),function(){
                         parent.window.dataReload();
                         Common.info("添加成功");
                         Lib.closeFrame();
                     });
                });
            });
            $("#updateButton").click(function(){
                form.on('submit(form)', function(){
                    sincerityApi.enterpriseUpdate($('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("更新成功");
                        Lib.closeFrame();
                    });
                });
            });
            $("#updateButton-cancel").click(function(){
                Lib.closeFrame();
            });
        
            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }
    			
    }
    exports('enterpriseadd',view);

    /*
        监听企业名称下拉框值变化 动态更新统一社会信用代码
     */
    form.on('select(workstationName)',function (data) {
        console.log($(data.elem).find("option:selected").attr("codeVal"))
        $("#organizationCode").val($(data.elem).find("option:selected").attr("codeVal"));
    });
});